﻿namespace PortableRiotGames.Interfaces.Game
{
    using Newtonsoft.Json;
    using PortableRiotGames.Infrastructure;
    using PortableRiotGames.Infrastructure.Converters;
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Response object for a list of champion information.
    /// </summary>
    [JsonObject(MemberSerialization.OptIn)]
    public sealed class GetRecentResponse : ResponseBase
    {
        /// <summary>
        /// List of recent games played (max 10).
        /// </summary>
        [JsonProperty("games")]
        public List<GetRecentResponseGame> Games { get; set; }

        /// <summary>
        /// Summoner ID.
        /// </summary>
        [JsonProperty("summonerId")]
        public long SummonerID { get; set; }
    }

    [JsonObject(MemberSerialization.OptIn)]
    public sealed class GetRecentResponseFellowPlayer
    {
        /// <summary>
        /// Champion id associated with player.
        /// </summary>
        [JsonProperty("championId")]
        public int ChampionID { get; set; }

        /// <summary>
        /// Summoner id associated with player.
        /// </summary>
        [JsonProperty("summonerId")]
        public long SummonerID { get; set; }

        /// <summary>
        /// Team ID associated with player.
        /// </summary>
        [JsonProperty("teamId")]
        public int TeamID { get; set; }
    }

    /// <summary>
    /// Game info.
    /// </summary>
    [JsonObject(MemberSerialization.OptIn)]
    public sealed class GetRecentResponseGame
    {
        /// <summary>
        /// Champion ID associated with game.
        /// </summary>
        [JsonProperty("championId")]
        public int ChampionID { get; set; }

        /// <summary>
        /// Date that end game data was recorded, converted from epoch milliseconds.
        /// </summary>
        [JsonProperty("createDate")]
        [JsonConverter(typeof(JsonDateTimeMiliConverter))]
        public DateTime CreateDate { get; set; }

        /// <summary>
        /// Other players associated with the game.
        /// </summary>
        [JsonProperty("fellowPlayers")]
        public List<GetRecentResponseFellowPlayer> FellowPlayers { get; set; }

        /// <summary>
        /// Game ID.
        /// </summary>
        [JsonProperty("gameId")]
        public long GameID { get; set; }

        /// <summary>
        /// Game mode.
        /// </summary>
        [JsonProperty("gameMode")]
        [JsonConverter(typeof(JsonGameModeConverter))]
        public GameMode GameMode { get; set; }

        /// <summary>
        /// Game type.
        /// </summary>
        [JsonProperty("gameType")]
        [JsonConverter(typeof(JsonGameTypeConverter))]
        public GameType GameType { get; set; }

        /// <summary>
        /// Invalid flag.
        /// </summary>
        [JsonProperty("invalid")]
        public bool Invalid { get; set; }

        /// <summary>
        /// Level.
        /// </summary>
        [JsonProperty("level")]
        public int Level { get; set; }

        /// <summary>
        /// Map.
        /// </summary>
        [JsonProperty("mapId")]
        [JsonConverter(typeof(JsonEnumConverter<Map>))]
        public Map Map { get; set; }

        /// <summary>
        /// ID of first summoner spell.
        /// </summary>
        [JsonProperty("spell1")]
        public int Spell1 { get; set; }

        /// <summary>
        /// ID of second summoner spell.
        /// </summary>
        [JsonProperty("spell2")]
        public int Spell2 { get; set; }

        /// <summary>
        /// Statistics associated with the game for this summoner.
        /// </summary>
        [JsonProperty("statistics")]
        public List<GetRecentResponseStatistic> Statistics { get; set; }

        /// <summary>
        /// Game sub-type.
        /// </summary>
        [JsonProperty("subType")]
        public string SubType { get; set; }

        /// <summary>
        /// Team ID associated with game.
        /// </summary>
        [JsonProperty("teamId")]
        public int TeamID { get; set; }
    }

    [JsonObject(MemberSerialization.OptIn)]
    public sealed class GetRecentResponseStatistic
    {
        /// <summary>
        /// Raw stat ID.
        /// </summary>
        [JsonProperty("id")]
        public int ID { get; set; }

        /// <summary>
        /// Raw stat name.
        /// </summary>
        [JsonProperty("name")]
        public string Name { get; set; }

        /// <summary>
        /// Raw stat value.
        /// </summary>
        [JsonProperty("value")]
        public int Value { get; set; }
    }
}